<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*
           *
           **
           ***
           ****
           *****

                *
               **
              ***
             ****
            *****
       */
        /* 
            1111*
            111**
            11***
            1****
            *****


            11111
            1111
            111
            11
            1
            *
            **
            ***
            ****
            *****
        */
        /* 
             i           j
             0           5
             1           4
             2           3
             3           2
             4           1
             i + j = 5;
             j = 5 - i;
 

             i           j
             0           1
             1           2
             2           3
             3           4
             4           5

             i + 1 = j
             i = j - i
        */

        for (let i = 0; i < 5; i++) {
            let star = '';
            let star1 = '';
            for (let j = 0; j < 5 - i; j++) {
                star = star + ' ';
            }
            for (let k = 0; k < i + 1; k++) {
                star1 = star1 + "*"
            }
            //console.log(star);  空格倒三角
            //console.log(star1); 星星正三角
            console.log(star + star1);
        }

    </script>
</body>

</html>